package com.craney.testBmp
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.PixelSnapping;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLRequest;
	
	public class SnappingAndSmoothing
	{
		private var parentSprite:Sprite;
		
		private var loader:Loader = new Loader();
		
		private var url:URLRequest = new URLRequest("dog.jpg");
		
		private var bmp:Bitmap = new Bitmap();
		
		private var bmpData:BitmapData = new BitmapData(140, 129);
		
		public function SnappingAndSmoothing(ps:Sprite)
		{
			
			parentSprite = ps;
			
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
			loader.load(url);
			
						
		}

		private function complete(event:Event):void
		{
			var loadInfo:LoaderInfo = event.target as LoaderInfo;
			trace(loadInfo.content.width);
			trace(loadInfo.content.height);
			
			bmpData.draw(loadInfo.content);
			bmp.bitmapData = bmpData;
			bmp.pixelSnapping = PixelSnapping.AUTO;
//			bmp.smoothing = true;
			
			bmp.scaleX = 3;
			bmp.scaleY = 3;
			
			parentSprite.addChild(bmp);
//			loader.x = 141;
			loader.y = 129;
			parentSprite.addChild(loader);
		}

	}
}